(function(angular) {
	'use strict';
	angular.module("fs.waf").factory("incomingRequestService", incomingRequestService)
	.filter("reqMsgStatus", [ '$filter', '$locale', 'incomingRequestService', function($filter, $locale, incomingRequestService) {
		return function(reqMsgStatus, pattern) {
			return $filter('translate')(incomingRequestService.reqMsgStatusFilter(reqMsgStatus, pattern));
		};
	} ]);
	incomingRequestService.$inject = [ '$q', 'loggerFactory' ];
	function incomingRequestService($q, loggerFactory) {
		var log = loggerFactory.getLogger("incomingRequestService");
		function initDataOptions($scope, ctrl) {
			ctrl.autoSettlementFlag = getIsDefaultsOptions();
		}
		
		function reqMsgStatusFilter(optionValue) {
			var options =[{label:"label.incomingrequest.created",value:"C"},{label:"label.incomingrequest.processed",value:"P"},{label:"label.incomingrequest.received",value:"R"},{label:"label.incomingrequest.error",value:"E"}];
			var optionLabel = '';
			if(options) {
				angular.forEach(options, function(obj, index) {
					if(optionValue == obj.value) {
						optionLabel = obj.label;
					}
				});
			}
			return optionLabel;
		}
		
		function getIsDefaultsOptions() {
			var option = {
					"data" : [{
						"value" : "Y",
						"label" : "label.global.yes"
					}, {
						"value" : "N",
						"label" : "label.global.no"
					} ]
			};
			return option;
		}
		
		return {
			reqMsgStatusFilter : reqMsgStatusFilter,
			initDataOptions : initDataOptions
		};
	}
})(angular);